import cv2
import matplotlib.pyplot as plt
import numpy as np

# 读取图像
img1 = cv2.imread("technology building.jpeg")

# 图像水平镜像
h, w = img1.shape[:2]
M = np.float32([[-1, 0, 520], [0, 1, 0]])
dst1 = cv2.warpAffine(img1, M, (w, h))

# 图像垂直镜像
h, w = img1.shape[:2]
M = np.float32([[1, 0, 0], [0, -1, 520]])
dst2 = cv2.warpAffine(img1, M, (w, h))

# 图像显示
fig, axes = plt.subplots(1, 3, figsize=(80, 10), dpi=100)
axes[0].imshow(img1[:, :, ::-1])
axes[0].set_title("original")
axes[1].imshow(dst1[:, :, ::-1])
axes[1].set_title("after horizontal-mirror")
axes[2].imshow(dst2[:, :, ::-1])
axes[2].set_title("after vertical-mirror")

plt.show()